#pragma once

#include "ConfigBase.h"
#include "XString.h"
#include "RegistryHelper.h"


#define REGISTRY_ROOT_KEY							_T("Config\\Collector\\Output")
#define REGISTRY_VALUE_LOCATION						_T("Location")

namespace config {

/**
 * Configuration of output files' location
 */
class OutputConfig : public ConfigBase {
public:
	OutputConfig(void) {
		platform::RegistryHelper::RegistryKey key(platform::RegistryHelper::RK_ABPA_BASE, REGISTRY_ROOT_KEY);
		key.getStringValue(REGISTRY_VALUE_LOCATION, m_sOutputLocation);
	}

	virtual ~OutputConfig(void) { save(); }

protected:
	virtual void do_save(void) const;

public:
	inline const platform::XString & getLocation(void) const { return m_sOutputLocation; }

	/** sets new output location */
	inline void setLocation(const platform::XString &loc) {
		m_sOutputLocation = loc;
		changed();
	}

	/**
	 * Builds a name for unique file, located in output directory
	 * @param ext extension of the file to be appended to the name
	 * @return name of the output file
	 */
	const platform::XString & getProcessOutputFile(const platform::XString &ext) const;

private:
	platform::XString m_sOutputLocation;
	mutable platform::XString m_sProcOutputFile;
};


} // end namespace